using System;
using System.Linq;

namespace Biotech.Common.Util
{
    public static class UtilData
    {
        public static int ReadInt32(byte[] Array, int index)
        {
            return BitConverter.ToInt32(Array, index);
        }

        public static short ReadInt16(byte[] Array, int index)
        {
            return BitConverter.ToInt16(Array, index);
        }

        public static uint ReadUint32(byte[] Array, int index)
        {
            return BitConverter.ToUInt32(Array, index);
        }

        public static ushort ReadUint16(byte[] Array, int index)
        {
            return BitConverter.ToUInt16(Array, index);
        }

        public static float ReadFP32(byte[] Array, int index)
        {
            return BitConverter.ToSingle(Array, index);
        }

        public static double ReadDouble(byte[] Array, int index)
        {
            return BitConverter.ToDouble(Array, index);
        }

        public static string ReadString(byte[] Array, int startIndex, int lenght)
        {
            return System.Text.Encoding.ASCII.GetString(Array.Skip(startIndex).ToArray());
            //return BitConverter.ToString(Array, startIndex, lenght);
        }

        public static bool GetBitValue(uint pValue, ushort pBitIndex)
        { 
            return (pValue & (0x01 << pBitIndex)) == 0?false:true;
        }
    }
}